package cn.db101.view;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class mainFrame {
	JFrame jf = new JFrame();
	private JPanel contentPane;

	/**
	 * Launch the application.
	 * public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					mainFrame frame = new mainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	 */
	

	/**
	 * Create the frame.
	 */
	public  void init() {//��װ��ͼ
		jf.setTitle("\u767B\u5F55主界面");
		
		jf.setIconImage(Toolkit.getDefaultToolkit().getImage(mainFrame.class.getResource("/icon/Libraries_64px_1176502_easyicon.net.png")));
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf.setBounds(100, 100, 1278, 805);
		
		JMenuBar menuBar = new JMenuBar();
		jf.setJMenuBar(menuBar);
		
		JMenu m1 = new JMenu("主界面");
		m1.setIcon(new ImageIcon(mainFrame.class.getResource("/icon/线性图书.png")));
		menuBar.add(m1);
		
		JMenu m2 = new JMenu("图书管理规定");
		m2.setIcon(new ImageIcon(mainFrame.class.getResource("/icon/线性老师.png")));
	
		
		menuBar.add(m2);
		
		JMenu m3 = new JMenu(" 图书查询");
		m3.setIcon(new ImageIcon(mainFrame.class.getResource("/icon/线性本子vg.png")));
		menuBar.add(m3);
		
		JMenu m4 = new JMenu(" \u6CE8\u518C");
		m4.setIcon(new ImageIcon(mainFrame.class.getResource("/icon/线性铅笔.png")));
		menuBar.add(m4);
		
		JMenu m5 = new JMenu("\u767B\u5F55");
		m5.setIcon(new ImageIcon(mainFrame.class.getResource("/icon/线性双指点击.png")));
		menuBar.add(m5);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		jf.setContentPane(contentPane);
		
		JLayeredPane layeredPane = new JLayeredPane();
		contentPane.add(layeredPane, BorderLayout.CENTER);
		
		JLabel label = new JLabel("\u767B\u5F55主界面");
		label.setIcon(new ImageIcon(mainFrame.class.getResource("/img/interface.png")));
		label.setBounds(0, 0, 1250, 722);
		layeredPane.add(label);
	
		m2.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {

				//���ٵ�ǰҳ��
				closeThis();
				//���´���
				new regulationFrame().init();
			}
		});	
		m3.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {

				//���ٵ�ǰҳ��
				closeThis();
				//���´���
				new searchFrame().init();
			}
		});	
		m4.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {

				//���ٵ�ǰҳ��
				closeThis();
				//���´���
				new registerFrame().init();
			}
		});	
		m5.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {

				//���ٵ�ǰҳ��
				closeThis();
				//���´���
				new loginFrame().init();
			}
		});	
		//���ô���ɼ�
		jf.setVisible(true);	
		//����JFrame������ʾ
		jf.setLocationRelativeTo(null);
	}
	
	public  void closeThis() {
		jf.dispose();
	}
	public static void main(String[] args) {//�ͻ������
		new mainFrame().init();	
	}
}
